
import 'dart:io';

import 'package:device_info_plus/device_info_plus.dart';
import 'package:dss_base/utils/log_util.dart';
import 'package:url_launcher/url_launcher.dart';

class DeviceUtil{

  DeviceUtil._();

  static Future<String> getDeviceModel() async {
    final deviceInfoPlugin = DeviceInfoPlugin();

    try {
      if (Platform.isAndroid) {
        final info = await deviceInfoPlugin.androidInfo;
        // 品牌 厂商 型号 版本
        // Redmi Xiaomi 24117RK2CC 15
        return '${info.brand} ${info.manufacturer} ${info.model} ${info.version.release}';
      } else if (Platform.isIOS) {
        final info = await deviceInfoPlugin.iosInfo;
        // iPhone17,2 iOS 18.5 iPhone 16 Pro Max
        return '${info.utsname.machine} ${info.systemName} ${info.systemVersion} ${info.name}';
      } else {
        return "Unsupported Platform";
      }
    } catch (e) {
      return "Error: $e";
    }
  }

  static Future<void> callPhoneNumber(String phoneNumber) async {
    final Uri url = Uri(scheme: 'tel', path: phoneNumber);
    if (await canLaunchUrl(url)) {
      await launchUrl(url);
    } else {
      Log.e('无法拨打电话');
    }
  }
}